//
//  JSTool.swift
//  Nairacup
//
//  Created by ec on 2024/9/19.
//

import Foundation

enum JSOptType {
    // Swift调JS，JS也调Swift
    case all
    // JS也调Swift
    case request
    // Swift调JS
    case response
}

enum JSStatus: Int {
    case success = 0
    case unAuth = 500
    case other = 999
}

enum JSMethod: String {
    
    // 获取用户信息
    case userInfo = "UserInfo"
    // 退出登录
    case signOut = "SignOut"
    // 风控-设备信息
    case deviceInfo = "DeviceInfo"
    // 风控-日历信息
    case calendarInfo = "CalendarInfo"
    // 选择通讯录人员
    case selectContact = "SelectContact"
    // sdk埋点
    case appsFlyer = "AppsFlyer"
    // 拍照-前置摄像头
    case tackPhotoByFront = "TackPhotoByFront"
    // 拍照-后置摄像头
    case tackPhotoByBack = "TackPhotoByBack"
    // 使用h5地址打开一个带头部导航的webview，带返回按钮
    case forwardOutside = "ForwardOutside"
    // 打开外部默认浏览器
    case openBrowser = "OpenBrowser"
    // 复制到剪切板
    case copyClip = "CopyClip"
    // 当前服务器时间
    case appServiceTime = "AppServiceTime"
    // 风控-定位信息
    case locationInfo = "LocationInfo"

    var id: String {
        switch self {
        case .userInfo:
            return "1"
        case .signOut:
            return "2"
        case .deviceInfo:
            return "3"
        case .calendarInfo:
            return "4"
        case .selectContact:
            return "5"
        case .appsFlyer:
            return "6"
        case .tackPhotoByFront:
            return "7"
        case .tackPhotoByBack:
            return "8"
        case .forwardOutside:
            return "9"
        case .openBrowser:
            return "10"
        case .copyClip:
            return "11"
        case .appServiceTime:
            return "12"
        case .locationInfo:
            return "13"
        }
    }
    
    var optType: JSOptType {
        switch self {
        case .userInfo,
            .deviceInfo,
            .calendarInfo,
            .selectContact,
            .tackPhotoByFront,
            .tackPhotoByBack,
            .locationInfo:
            return .all
        case .signOut,
            .appsFlyer,
            .forwardOutside,
            .openBrowser,
            .copyClip,
            .appServiceTime:
            return .request
        }
    }
    
}
